// imgSize.js
//  图片尺寸限制
const imgSize = (file) => {
  return new Promise((resolve, reject) => {
    let url = window.URL || window.webkitURL;
    let img = new Image();
    img.onload = function () {
      // 图片比例校验
      let valid = img.width / img.height === 1.875;
      valid ? resolve() : reject();
    };
    img.src = url.createObjectURL(file);
  }).then(
    () => {
      return file;
    },
    () => {
      return Promise.reject();
    }
  );
}

export default imgSize;
